package com.jwetherell.my.search;

import java.util.ArrayList;
import java.util.List;

public class TestSearch {

	public static void main(String[] args) {
		int [] data = getSortedDataUniformlyDistributed();
		printData(data);
		
		int key = 15;
		System.out.println("Index of key: " + SearchAlgos.binarySearch(data, key));
		System.out.println("Index of key: " + SearchAlgos.interpolationSearch(data, key));
		
	}

	private static void printData(int[] data) {
		System.out.print("Data: ");
		for (int i = 0; i < data.length; i++)
			System.out.print(data[i] + "[" + i + "], ");
		System.out.print("\n");
	}

	private static int[] getSortedDataUniformlyDistributed() {
		List<Integer> data = new ArrayList<Integer>();
		data.add(2);
		data.add(3);
		data.add(7);
		data.add(14);
		data.add(20);

		int [] arrayData = new int[data.size()];
		for (int i = 0; i < data.size(); i++) {
			arrayData[i] = data.get(i);
		}
		
		return arrayData;
	}
	
	private static int[] getSortedDataNotUniformlyDistributed() {
		return new int[] {2, 3, 7, 14, 20};
	}
}
